<template> 	
  <div class="page">
	<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						
						<div class="layui-card-body">							
							<div class="layui-form" lay-filter="">																																												    						   													    
						    <div class="layui-form-item">
									<label class="layui-form-label">头像</label>
						      <div class="layui-input-inline">
						         <div class="layui-upload">										
										  <div class="layui-upload-list">
										    <img class="layui-upload-img" :src="itemData.imageUrl?itemData.imageUrl:'http://kedoujfpc.tongdui365.com/static/common/image/zwyl.jpg'" width="100" height="100" style="border:1px solid #eee;">										   
										  </div>
										</div>
						      </div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">昵称</label>
									    <div class="layui-input-inline" >
									        <input type="text" name="nickName" disabled="disabled" placeholder="请输入昵称"  v-model="itemData.nickName" autocomplete="off" class="layui-input a" maxlength="11">
									    </div>										   
								  </div>
								</div>	
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">手机号码</label>
									    <div class="layui-input-inline" >
									        <input type="number" name="mobile" disabled="disabled" placeholder="用户手机号"  v-model="itemData.mobile" autocomplete="off" class="layui-input" maxlength="11">
									    </div>										   
								  </div>
								</div>
								<div class="layui-form-item">
							    <label class="layui-form-label">加入时间</label>
							    <div class="layui-input-inline" >
							        <input type="text" name="createAt" disabled="disabled" placeholder=""  v-model="createAt" autocomplete="off" class="layui-input" maxlength="">
							    </div>	
							  </div>
								<div class="layui-form-item">
							    <label class="layui-form-label">性别</label>
							    <div class="layui-input-block">
							      <input type="radio" name="sex" :value="itemData.sex==1" title="男" checked>
							      <input type="radio" name="sex" :value="itemData.sex==2" title="女">
							    </div>
							  </div>
							  <div class="layui-form-item">
							    <label class="layui-form-label">婚否</label>
							    <div class="layui-input-block">
							      <input type="radio" name="maritalStatus" :value="itemData.maritalStatus==1?'checked':''" title="是">
							      <input type="radio" name="maritalStatus" :value="itemData.maritalStatus==2?'checked':''" title="否">
							    </div>
							  </div>
							  <div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">出生年月</label>
									    <div class="layui-input-inline" >
									        <input type="number" name="birthdate" disabled="disabled" placeholder=""  v-model="birthdate" autocomplete="off" class="layui-input" maxlength="">
									    </div>										   
								  </div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">行业</label>
									     <div class="layui-input-block">
									      <input type="text"  name="trade"  placeholder="请输入"  v-model="itemData.trade" autocomplete="off" class="layui-input" maxlength="">
									     </div>									   
								  </div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">公司</label>
									     <div class="layui-input-block">
									      <input type="text"  name="company"  placeholder="请输入"  v-model="itemData.company" autocomplete="off" class="layui-input" maxlength="">
									     </div>									   
								  </div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">职业</label>
									     <div class="layui-input-block">
									      <input type="text"  name="profession"  placeholder="请输入"  v-model="itemData.profession" autocomplete="off" class="layui-input" maxlength="">
									     </div>									   
								  </div>
								</div>								
								<div class="layui-form-item layui-form-text">
							    <label class="layui-form-label">地址</label>
							    <div class="layui-input-block">
							      <textarea name="address" placeholder="" v-model="itemData.address" class="layui-textarea"></textarea>
							    </div>
							  </div>			
								<!--<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">状态</label>
									    <div class="layui-input-inline">
												<select name="referrerId" lay-filter="referrerId"  v-model="itemData.referrerId">
													<option value="1">启用</option>	
												  <option value="2">禁用</option>											  
												</select>
											</div>											   
								  </div>
								</div>-->
								<div class="layui-form-item">
									<div class="layui-input-block">
										<button class="layui-btn layui-btn-normal" lay-submit lay-filter="setmyinfo" @click="confirmOk">确定</button>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>		
		<input type="hidden" id='id'/>
  </div> 
</template>
<script>
export default {	
  name: 'customerdetail',  
  data () {
    return { 
    	id:'',
    	curindex:1, //页数    	    	    	
    	itemData:{
	      customerShopDTO:{},	          	       	            
	    },
	    birthdate:'',
	    createAt:'',
	    title:'',	//备注名称   
    }
  },
  mounted(){ 
  	var _this = this;   	
	  window.getdates = this.getdates;  
  },
  methods: {  	
		getdates:function(data){		
			var _this = this; 			
			_this.id=data.id;
		//	_this.where=data.where;
//			var dates={
//					id:_this.id,	
//					where:_this.where,
//			}			
			var url="/crmweb/bapi/v1.9/customer/"+_this.id						
			ajaxRequest(url,'GET','json','',function(ret,err){
				//alert(url+"///"+JSON.stringify(ret))
				 _this.itemData=ret.data;
				 _this.createAt=FormatDate(ret.data.createAt,2)
				if(ret.data.birthdate){
				  _this.birthdate=FormatDate(ret.data.birthdate,2)
				}
//				if(ret.data.CustomerShopVM){
//			    _this.title=ret.data.CustomerShopVM.title;
//		    }				
			})			
	},		
		confirmOk:function(){
			var _this=this;				
//			var len = $(".a").length;
//			for(var i = 0; i < len; i++) {
//				if($(".a").eq(i).val() == ''||$(".a").eq(i).val()<=0) {
//					var msg = $(".a").eq(i).attr("placeholder");
//					layer.msg('请输入正确的'+msg);
//					return;
//				}
//			}				
			 var dates={
		       id:_this.itemData.id,
		       mobile:_this.itemData.mobile,
		       userName:_this.itemData.userName,
		       realName:_this.itemData.realName,
		       nickName:_this.itemData.nickName,
		       sex:_this.itemData.sex,
		       trade:_this.itemData.trade,
		       company:_this.itemData.company,	
		       profession:_this.itemData.profession,
		       maritalStatus:_this.itemData.maritalStatus,
		       address:_this.itemData.address,
		       imageUrl:_this.itemData.imageUrl,
		       gradeType:_this.itemData.gradeType,		    	            
		       createAt:_this.itemData.createAt,
		       birthdate:_this.birthdate1,
		       customerShopDTO:{		        
		           id:_this.itemData.customerShopVM.id,
		           title:_this.itemData.customerShopVM.title,		         
		       },
		   }		  		    		  		   		  		
	     // alert(JSON.stringify(dates))
	    var url="/crmweb/bapi/v1.9/customer"//编辑										
			ajaxRequest(url,'PUT', 'JSON', dates, function(ret, err){
				//alert(JSON.stringify(dates)+"///"+JSON.stringify(ret))
				layer.msg('操作成功！');
				setTimeout(function(){
			  	var index = parent.layer.getFrameIndex(window.name);	          	
			    parent.layer.close(index);
		      parent.location.reload(); 
	      },1000)
			})
		},
  },
   updated:function(){
		this.isShow = true;
		var _this=this;
		layui.use('form', function(){
		  var form = layui.form;
		  form.render();
//		  form.on("select(status)", function(data){										
//			   _this.itemData.status = data.value
//		  });
//		  form.on("select(userTypeId)", function(data){	
//		  	//alert(JSON.stringify(data))
//			   _this.itemData.userTypeId = data.value
//		  });
		});
  },

}
</script>
<style scoped>
	.red{color:#ff0000;}
	.layuitj{float:left;line-height:38px;color:#FF0000;}
	.layuitj1{margin-left:20px;}
</style>
